
/**
 * @Project : Clion_ProgrammingExercises
 * @File : 0789
 * @Author : WangRuoyu 
 * @Date : 2023/5/20 11:13
 */

#include "iostream"

using namespace std;

int main() {
    int n, m;
    scanf("%d %d", &n, &m);
    int a[n];
    for (int i = 0; i < n; ++i) {
        scanf("%d", &a[i]);
    }

    for (int i = 0; i < m; ++i) {
        int x;
        scanf("%d", &x);
        int l = 0;
        int r = n - 1;
        while (l < r) {
            int mid = (l + r) >> 1;
            if (a[mid] >= x) r = mid;
            else l = mid + 1;
        }
        if (a[l] != x) {
            printf("-1 -1\n");
            continue;
        }

        int ll = l;
        l = 0;
        r = n - 1;
        while (l < r) {
            int mid = (l + r + 1) >> 1;
            if (a[mid] <= x) l = mid;
            else r = mid - 1;
        }
        printf("%d %d\n", ll, l);
    }
    return 0;
}
